package edu.yourl.persistence;

import java.util.List;

import com.db4o.query.Query;

import edu.yourl.domain.Gossip;

public class GossipRepository extends AbstractRepository implements IGossipRepository {

	/* (non-Javadoc)
	 * @see edu.yourl.persistence.IGossipRepository#get(edu.yourl.domain.Gossip)
	 */
	public Gossip get(Gossip gossip) {
		return (Gossip) this.getDb4oTemplate().getObjectContainer().queryByExample(gossip)
				.next();
	}

	@Override
	public void add(Gossip gossip) {
		super.add(gossip);		
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Gossip> search(final String search) {
		Query query = getDb4oTemplate().query();
		query.constrain(Gossip.class);
		query.descend("message").constrain(search).like();
		return query.execute();
	}

}
